const a = async function (...args) {
  const [d, l] = args.slice(-2);
  const { memory } = d;
  const {
    dc: { http, message, reload },
    xe: { get, set },
  } = l;
  const checkList = [
    ...get(memory, "checkListBonus", []),
    ...get(memory, "checkListBx", []),
  ];
  if (!checkList.length) return message.info("请至少选择一条数据");
  set(memory, "saveBtnLoading", true);
  try {
    const errorList = [];
    function toUp(str) {
      let newStr = "";
      let arr = str.split("_");
      arr.forEach((item, index) => {
        if (index > 0) {
          return (newStr += item.replace(item[0], item[0].toUpperCase()));
        } else {
          return (newStr += item);
        }
      });
      return newStr;
    }
    for (const item of checkList) {
      const params = {};
      Object.keys(item).forEach((key) => {
        params[toUp(key)] = item[key];
      });
      const res = await http.post(
        {
          url: "/ypxy/transfer/submit",
          data: { ...params, id: undefined },
        },
        { isTransformResponse: false }
      );
      if (res.code !== 200) {
        errorList.push(params.programName);
      }
    }
    if (errorList.length) {
      message.error(`项目${errorList.join(",")}审核失败`);
    } else {
      message.success("提交审核成功");
    }
    set(memory, "saveBtnLoading", false);
    if (errorList.length !== checkList.length) {
      reload({ from: "1790218686092136450" });
      reload({ from: "1790217412655304705" });
      set(memory, "checkListBonus", []);
      set(memory, "checkListBx", []);
    }
  } catch (error) {
    set(memory, "saveBtnLoading", false);
  }
};

const a1 = async function (...args) {
  const [d, l] = args.slice(-2);
  const {
    origin,
    owner: { memory },
  } = d;
  const {
    dc: { close, http },
    xe: { get, set },
  } = l;
  const data = get(origin, "1785949436933836801");
  if (!data) return;
  set(memory, "modal", true);
  console.log("modal button click: ", d, l, data);
  await http.post({ url: "/nyk/program/modifyProgram", data });
  const { guid, tagList = [] } = data;
  await http.post({
    url: "/nyk/tag/insertTableTag",
    data: { guid, idList: tagList, type: "PROGRAM" },
  });
  close();
};

const b = async function (...args) {
  const [d, l] = args.slice(-2);
  const { origin, memory } = d;
  const {
    dc: { close, http, message, setModal, reload },
    xe: { get, set },
  } = l;
  console.log(...args);
  return reload({ from: "1790218686092136450" });
  const checkList = [
    ...get(memory, "checkListBonus", []),
    ...get(memory, "checkListBx", []),
  ];
  console.log(checkList, args);
  if (!checkList.length) return message.info("请至少选择一条数据");
  setModal({ confirmLoading: true });
  try {
    const errorList = [];
    function toUp(str) {
      let newStr = "";
      let arr = str.split("_");
      arr.forEach((item, index) => {
        if (index > 0) {
          return (newStr += item.replace(item[0], item[0].toUpperCase()));
        } else {
          return (newStr += item);
        }
      });
      return newStr;
    }
    for (const item of checkList) {
      const params = {};
      Object.keys(item).forEach((key) => {
        params[toUp(key)] = item[key];
      });
      const res = await http.post(
        { url: "/ypxy/transfer/submit", data: { ...params, id: undefined } },
        { isTransformResponse: false }
      );
      if (res.code !== 200) {
        errorList.push(params.programName);
      }
    }
    if (errorList.length) {
      message.error(`项目${errorList.join(",")}审核失败`);
    } else {
      message.success("提交审核成功");
    }
    setModal({ confirmLoading: false });
    if (errorList.length !== checkList.length) {
      console.log(123123);
      reload();
    }
  } catch (error) {
    setModal({ confirmLoading: false });
  }
};
